#!/bin/sh -e

. CI/travis/lib.sh

# Remove .git repo and see how it performs
if [ "$TEST_NON_GIT_REPO" = "1" ] ; then
	rm -rf .git
fi

handle_default() {
	mkdir -p build
	cd build
	if [ -n "$PACKAGE_TO_INSTALL" ] || [ "$INSTALL_FROM_SW_DOWNLOADS" = "1" ] ; then
		cmake ..
		make
	else
		export PKG_CONFIG_PATH="$STAGINGDIR/lib/pkgconfig:$PKG_CONFIG_PATH" ; \
		cmake -DCMAKE_PREFIX_PATH="$STAGINGDIR" -DCMAKE_INSTALL_PREFIX="$STAGINGDIR" \
			-DCMAKE_EXE_LINKER_FLAGS="-L${STAGINGDIR}/lib" ..
		CFLAGS=-I${STAGINGDIR}/include LDFLAGS=-L${STAGINGDIR}/lib make
	fi
	cd ..
}

handle_centos() {
	handle_default
}

handle_ubuntu() {
	handle_default
}

handle_debian() {
	handle_default
}

handle_generic_docker() {
	run_docker_script inside_docker.sh
}

setup_build_type_env_vars

handle_${BUILD_TYPE}
